package echat.future.cn.echat.home

import android.content.Context
import android.view.Gravity
import android.view.View
import com.zhusx.core.app._BaseDialog
import echat.future.cn.echat.R
import echat.future.cn.echat.home.bean.DearEntity
import echat.future.cn.echat.home.tools.loadHeaderImage
import echat.future.cn.echat.my.utils.ToastUtils
import kotlinx.android.synthetic.main.dialog_dear.*

/**
 *
 * Author  zhusx
 * Email   327270607@qq.com
 * Create  2018/8/10 11:30
 */
class BottomDearDialog(context: Context, data: DearEntity) : _BaseDialog<String>(context, R.style.dialogBottom) {
    init {
        setContentView(R.layout.dialog_dear)
        _setGravity(Gravity.BOTTOM)
        iv_image.loadHeaderImage(data.user_avatar)
        tv_name.text = data.username
        tv_level.text = "LV.${data.level ?: "0"}"
        tv_sign.text = "个性签名:${data.sign ?: ""}"
        tv_post.text = "消费 ${data.used_money} 个E币"
        tv_get.text = "财富 ${data.treasure} 个E币"
        when (data.anchor_status) {
            "0" -> {
                iv_status.setImageResource(R.drawable.btn_lixian)
                tv_im.setOnClickListener {
                    ToastUtils.toastMsg(it.context, "当前主播不在线，请稍后再来")
                }
            }
            "1" -> {
                iv_status.setImageResource(R.drawable.btn_zaixian)
                tv_im.setOnClickListener {
                    //TODO 和她聊天
                }
            }
            else -> {
                iv_status.setImageResource(R.drawable.btn_lixian)
                tv_im.setOnClickListener {
                    ToastUtils.toastMsg(it.context, "当前主播不在线，请稍后再来")
                }
            }
        }
        iv_v.visibility = if (data.user_role == 2) View.VISIBLE else View.GONE

    }
}